﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using PowerCreator.LMS.Common.Script;

public partial class Theme_Index_ShowResourceDescription : System.Web.UI.Page
{
    private int rid = 0;
    private string ClassID= "0";
    private string CourseID= "0";
    private string CourseResourceID= "0";
    private string UserID= "0";
    private PowerCreator.LMS.Web.DL.User.LoginEntity login = new PowerCreator.LMS.Web.DL.User.LoginEntity();
    private string url = "UserLogin.aspx";
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUser();
        if (Request.QueryString["rid"] != null)
        {
            rid = int.Parse(Request.QueryString["rid"].ToString());
            Session["TG_ResourceID"] = rid;
            CourseResourceID = Request.QueryString["CourseResourceID"].ToString();
            CourseID = Request.QueryString["CourseID"].ToString();
            ClassID = Request.QueryString["ClassID"].ToString();
            BinderPage(rid, ClassID, CourseID, CourseResourceID, UserID);
        }


    }
    private void CheckUser()
    {
        if (Session[PowerCreator.LMS.Web.Config.WebConfig.SESSION_USER_USERINFO] == null)
        {
            Script.RedirectURL(url);
        }

        login = (PowerCreator.LMS.Web.DL.User.LoginEntity)Session[PowerCreator.LMS.Web.Config.WebConfig.SESSION_USER_USERINFO];
        if (login == null)
        {
            Script.RedirectURL(url);
        }
        UserID = login.UserID.ToString();
    }
    private void BinderPage(int rid,string claid,string couid,string crid,string uid)
    {
        PowerCreator.LMS.Course.Entity.VOTResource vo = new PowerCreator.LMS.Course.Entity.VOTResource();
        PowerCreator.LMS.Web.Course.Course obj=new PowerCreator.LMS.Web.Course.Course();
        vo = obj.LoadResource(rid);
        lbl_content.Text = vo.ResourceDescription;
        vo.ResourceClickNum += 1;
        vo.ResourceLastVisitTime = DateTime.Now;
        obj.UpdateResource(vo);
        AddTStudentStudyCouReslog(rid,claid,couid,crid,uid);
    }
    private void AddTStudentStudyCouReslog(int rid,string claid,string couid,string crid,string uid)
    {
        PowerCreator.LMS.Project.Entity.VOTStudentStudyCouReslog vo = new PowerCreator.LMS.Project.Entity.VOTStudentStudyCouReslog();
        PowerCreator.LMS.Project.Core.ProjectPlan obj = new PowerCreator.LMS.Project.Core.ProjectPlan();
        vo.FKSscrlogCourseresID = int.Parse(crid);
        vo.FKSscrlogCourseID = int.Parse(couid);
        vo.FKSscrlogPaperID = 0;
        vo.FKSscrlogProresID = 0;
        vo.FKSscrlogResourceID = rid;
        vo.FKSscrlogTrainclaID = int.Parse(claid);
        vo.FKSscrlogTrainproID = 0;
        vo.FKSscrlogUserID = int.Parse(uid);
        vo.SscrlogClass = 1;
        vo.SscrlogCurrentPosition = 0;
        vo.SscrlogEndTime = DateTime.Now;
        vo.SscrlogStartTime = DateTime.Now;
        vo.SscrlogTotalTime = 0;
        vo.Createtime = DateTime.Now;
        int id=0;
        obj.AddProjectResourceResourceHistory(vo, ref id);

        //更新进度
    }
}
